import { Controller, Post, Get, Body } from '@nestjs/common';
import { CartService, CartItem } from '../service/cart.service';

class AddItemDto {
  productId: string;
  quantity: number;
}

@Controller('cart')
export class CartController {
  constructor(private readonly cartService: CartService) {}

  @Post('items')
  addItem(@Body() addItemDto: AddItemDto): string {
    return this.cartService.addItem(addItemDto.productId, addItemDto.quantity);
  }

  @Get('items')
  getItems(): CartItem[] {
    return this.cartService.getItems();
  }
}